/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2024-09-29 10:06:10
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2024-09-29 10:12:54
 * @FilePath: /react18-vite-admin/src/components/ui/AppLink/AppLink.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { Link } from 'react-router-dom';
import type { ReactNode } from 'react';

import { isExternal } from '@/utils/index';

const AppLink = (props: { to: string; children: ReactNode }) => {
    const { to, children } = props;
    if (isExternal(to)) {
        return (
            <a href={to} target="_blank">
                {children}
            </a>
        );
    }
    return <Link to={to}>{children}</Link>;
};

export default AppLink;
